package com.qidian.mes.pro.service.impl;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.qidian.mes.pojo.OrderBOM;
import com.qidian.mes.pro.mapper.BOMMapper;
import com.qidian.mes.pro.service.MaterialBOMService;
import com.qidian.mes.util.dot.PagerDTO;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: CoolPro
 * @Description:
 * @Time: 2024-04-08 15:22
 **/
@Service
public class MaterialBOMServiceImpl implements MaterialBOMService {
    @Autowired
    private BOMMapper BOMMapper;
    @Override
    public QdResult findByOrderId(Long woId) {
        return QdResult.success(BOMMapper.findByWoId(woId));
    }

    @Override
    public QdResult findByBomId(Long bomId) {
        return QdResult.success(BOMMapper.findByBomId(bomId));
    }

    @Override
    public QdResult<PagerDTO<OrderBOM>> queryPager(OrderBOM orderBOM, int start, int limit) {
        PagerDTO<OrderBOM> pagerDTO = new PagerDTO();
        pagerDTO.setPage(start);
        pagerDTO.setLimit(limit);
        pagerDTO.setTotal(BOMMapper.selectCount(orderBOM));
        List<OrderBOM> list = BOMMapper.queryByPage(orderBOM,(start-1)*limit,limit);
        pagerDTO.setData(list);
        return QdResult.success(pagerDTO);
    }

}
